In [1]:
print("\x1b[31m\"red\"\x1b[0m")


"red"

In [2]:
print('\x1b[1;31m'+'Hello world'+'\x1b[0m')


Hello world

In [3]:
import sys
from termcolor import colored, cprint

text = colored('Hello, World!', 'red', attrs=['reverse', 'blink'])
print(text)
cprint('Hello, World!', 'green', 'on_red')

print_red_on_cyan = lambda x: cprint(x, 'red', 'on_cyan')
print_red_on_cyan('Hello, World!')
print_red_on_cyan('Hello, Universe!')

for i in range(10):
    cprint(i, 'magenta', end=' ')

cprint("Attention!", 'red', attrs=['bold'], file=sys.stderr)


Hello, World!
Hello, World!
Hello, World!
Hello, Universe!
0 1 2 3 4 5 6 7 8 9 
Attention!

Insults package


In [11]:
from insults import Insults


Traceback (most recent call last):

  File "/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-11-a5c49c3685f6>", line 1, in <module>
    from insults import Insults

  File "/usr/local/lib/python3.5/dist-packages/insults/__init__.py", line 1, in <module>
    from insults.core import Insults

  File "/usr/local/lib/python3.5/dist-packages/insults/core.py", line 1, in <module>
    from insults import classifier

  File "/usr/local/lib/python3.5/dist-packages/insults/classifier.py", line 7, in <module>
    from insults import util

  File "/usr/local/lib/python3.5/dist-packages/insults/util.py", line 258
    print pandas.DataFrame(data, columns=("fn", "score", "public", "private")).sort('score')
               ^
SyntaxError: invalid syntax

In [12]:
comment = "You are a disgusting maggot of a person."
Insults.load_model()
print(Insults.rate_comment(comment))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-12-ab508a2bd271> in <module>()
      1 comment = "You are a disgusting maggot of a person."
----> 2 Insults.load_model()
      3 print(Insults.rate_comment(comment))

NameError: name 'Insults' is not defined

In [13]:
comments = ["You called me a \"dickhead\", so I'll say you're a cunt.", "These shitakes taste like shit."]
print(Insults.foul_language(comments, context=False))


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-13-1642418947d5> in <module>()
      1 comments = ["You called me a \"dickhead\", so I'll say you're a cunt.", "These shitakes taste like shit."]
----> 2 print(Insults.foul_language(comments, context=False))

NameError: name 'Insults' is not defined

In [14]:
import regex as re

print(re.findall(r'"(.*?)"', comments[0]))


['dickhead']

In [ ]: